Temples:

(“Temple”, “Temples”, “House of God”, “House of the Lord”)

President Gordon B. Hincley Temples Header

Temple construction has boomed since 1995. From 1995 to 2020 the world went from 47 to 168 in operation. This is an unprecedented increase!

Of temples President Hinckley said, “We are determined, brethren, to take the temple to the people and afford them every opportunity for the very precious blessings that come of temple worship.” October 1997 Address

Through the design and construction of smaller temples, and an increase in the rate at which temples were announced and built, President Hinckley introduced the church to a new age of temple availability that continues to this day. Has this boom in temple availability lead to an increased mentions of temple related words in General Conference?

# Create a new column to count occurrences of the specified words
temple_data <- talks_data %>%
  mutate(
    temple_count = str_count(tolower(text), "\\btemple\\b"),
    temples_count = str_count(tolower(text), "\\btemples\\b"),
    house_of_the_lord_count = str_count(tolower(text), "\\bhouse of the lord\\b"),
    house_of_god_count = str_count(tolower(text), "\\bhouse of god\\b")
  ) %>% 
  mutate(
    total_temple = temple_count + temples_count + house_of_the_lord_count + house_of_god_count
  )

Scatter Plots

This plot shows there seems to be an increase in temple-related words following President Hinckley’s sustaining as prophet. The large gap in the middle is due to the sudden jump from 63 temples in 1999 to 102 temples in 2000. There are no dots through that section because no General Conference addresses were given in that time frame.

temple_by_year <- temple_data %>% 
  group_by(year) %>% 
  summarise(total = sum(total_temple)) %>% 
  mutate(temples = map_int(year, ~ sum(dedication_data$year <= .x)))

ggplot(data = temple_by_year) +
  geom_point(mapping = aes(x = temples, y = total), color = "forestgreen") +
  geom_vline(xintercept = 47, color = "red") +
  theme_bw() +
  labs(
    title = "Use of Temple Related Words in General Conference Talks",
    subtitle = "1995 Highlighted - Year President Gordon B. Hinckley became Church President",
    caption = '"Temple", "Temples", "House of God", "House of the Lord"',
    x = "Number of Dedicated Temples",
    y = "Mentions of the Temple"
  )

This plot shows the number of temples in the world by year:

graph <- ggplot(data = temple_by_year) +
  geom_point(mapping = aes(x = year, y = temples), color = "forestgreen", size = 1) +
  geom_line(mapping = aes(x = year, y = temples), color = "forestgreen") +
  theme_bw() +
  labs(
    title = "Number of Temples in the World by Year",
    subtitle = "Data is representing the count of dedicated temples at the end of the year",
    x = "Year",
    y = "Number of Dedicated Temples"
  ) 

graph

This time the phrases are shown in different colors.

temple_pivot <- temple_data %>% 
  select(year, speaker, title, temple_count, temples_count, house_of_the_lord_count, house_of_god_count) %>% 
  pivot_longer(
    cols = c(temple_count, temples_count, house_of_the_lord_count, house_of_god_count),
    names_to = "type",
    values_to = "count"
  ) %>% 
  group_by(year, type) %>% 
  summarise("total" = sum(count))

ggplot(data = temple_pivot) +
  geom_point(mapping = aes(x = year, y = total, color = type)) +
  geom_vline(xintercept = 1995, color = "red") +
  theme_bw() +
  labs(
    title = "Use of Temple Related Words in General Conference Talks",
    subtitle = "1995 Highlighted - Year President Gordon B. Hinckley became Church President",
    caption = '"Temple", "Temples", "House of God", "House of the Lord"',
    color = "Mention Type",
    x = "Year",
    y = "Mentions of the Temple"
  )

Box Plot

This boxplot shows that there is an increase in temple-related words between before President Hinckley was the prophet and our current Post-President Hinckley era. It seems temples are being talked about more now than they were before his sustaining.

temple_boxes <- temple_by_year %>% 
  mutate(group = case_when(
    year < 1995 ~ "Before Hinckley",
    year >= 1995 ~ "Post Hinckley"
  ))


ggplot(data = temple_boxes) + 
  geom_boxplot(mapping = aes(x = group, y = total)) + 
  theme_bw()

T Test

This T Test is a statistical test meant to tell us if the means of both populations differ from each other. Because our result (3.039e-06) is smaller than the confidence interval of 95% we can conclude the two means are significantly different. On top of that, based on the box plots of the previous tab, it is easy to conclude that Temples are mentioned more after President Hinckley than before he was the prophet!

t.test(total ~ group, data = temple_boxes, mu = 0, alternative = "two.sided", conf.level = 0.95) %>% 
  pander()
Welch Two Sample t-test: total by group (continued below)
Test statistic df P value Alternative hypothesis
-5.255 50.19 3.039e-06 * * * two.sided
mean in group Before Hinckley mean in group Post Hinckley
107.1 177.6

Book of Mormon:

(“Book of Mormon”)

President Ezra Taft Benson Book of Mormon Header

1986 was a big year for the Book of Mormon. President Ezra Taft Benson delivered a General Conference talk instructing members to use the Book of Mormon in teachings.

“This is a gift of greater value to mankind than even the many wonderful advances we have seen in modern medicine” October 1996 Address

How did this calling to action effect the number of quotes from the Book of Mormon in General Conference talks?

bom_data <- talks_data %>%
  mutate(
    total_bom = str_count(tolower(text), "(?i)\\bbook of mormon\\b")
  )

Scatter Plots

bom_by_year <- bom_data %>% 
  group_by(year) %>% 
  summarise(total = sum(total_bom))

ggplot(data = bom_by_year) +
  geom_point(mapping = aes(x = year, y = total), color = "forestgreen") +
  geom_vline(xintercept = 1986, color = "red") +
  theme_bw() +
  labs(
    title = "Use of Book of Mormon Related Words in General Conference Talks",
    subtitle = "1986 Highlighted - Year President Ezra Taft Benson Reaffirmed the Book of Mormon",
    caption = '"Book of Mormon"',
    x = "Year",
    y = "Mentions of the Book of Mormon"
  )

Are the scriptures from the book of mormon quoted more now than in the 70’s before the talk?

bom_quotes <- quotes %>% 
  filter(overall_book == "Book of Mormon") %>% 
  group_by(talk_year) %>% 
  summarise(total = n())

ggplot(data = bom_quotes, aes(x = talk_year, y = total)) + 
  geom_point(color = "red2") + 
  geom_smooth(method = lm, se = FALSE, color = "orange", linetype = "solid") +
  geom_vline(xintercept = 1986, color = "blue3") +
  theme_bw() +
  labs(
    title = "Quotes from the Book of Mormon in General Conference Talks",
    subtitle = "1986 Highlighted - Year President Ezra Taft Benson Reaffirmed the Book of Mormon",
    caption = '"Book of Mormon"',
    x = "Year",
    y = "Quotes from the Book of Mormon"
  )

mylm <- lm(total ~ talk_year, data = bom_quotes)
summary(mylm) %>% 
  pander()
  Estimate Std. Error t value Pr(>|t|)
(Intercept) -2513 852.3 -2.948 0.004812
talk_year 1.35 0.4268 3.163 0.002627
Fitting linear model: total ~ talk_year
Observations Residual Std. Error \(R^2\) Adjusted \(R^2\)
53 47.53 0.164 0.1476

Box Plot

bom_boxes <- bom_quotes %>% 
  mutate(group = case_when(
    talk_year < 1986 ~ "Before Talk", 
    talk_year >= 1986 ~ "Post Talk"
  ))

bom_means <- bom_boxes %>% 
  group_by(group) %>% 
  summarise(mean = mean(total))

ggplot(data = bom_boxes) + 
  geom_boxplot(mapping = aes(x = group, y = total)) + 
  geom_point(data = bom_means, mapping = aes(x = group, y = mean), color = "red3") +
  theme_bw()

T Test

t.test(total ~ group, data = bom_boxes, mu = 0, alternative = "two.sided", conf.level = 0.95) %>% 
  pander()
Welch Two Sample t-test: total by group (continued below)
Test statistic df P value Alternative hypothesis
-5.16 38.8 7.634e-06 * * * two.sided
mean in group Before Talk mean in group Post Talk
141.3 200

Bible Comparison

bible_compare <- quotes %>% 
  filter(overall_book %in% c("Book of Mormon", "Bible")) %>% 
  group_by(talk_year, overall_book) %>% 
  summarise(total = n())

ggplot(data  = bible_compare) + 
  geom_point(mapping = aes(x = talk_year, y = total, color = overall_book)) + 
  geom_smooth(se = FALSE, mapping = aes(x = talk_year, y = total, color = overall_book)) + 
  theme_bw()

Is there a difference in boxplots Pre President Benson and Post President Benson?

benson_check <- bible_compare %>% 
  mutate(group = case_when(
    talk_year < 1986 ~ "Before Talk",
    talk_year >= 1986 ~ "Post Talk"
  )) %>% 
  mutate(overall_group = paste(overall_book, group, sep = " - "))

ggplot(data = benson_check) + 
  geom_boxplot(mapping = aes(x = overall_group, y = total, fill = overall_book)) + 
  theme_bw()

Gathering Israel

(“Gathering Israel”, “Both Sides of the Veil”)

President Ezra Taft Benson Book of Mormon Header

The main focus of President Nelson’s ministry is, “Gathering Israel on both sides of the veil”. This focus includes missionary work, temple work, and each individual’s commitment to following the covenant path.

Has this focus permeated the church as a whole? Here we have conducted a simple word analysis to determine if phrases related to gathering Israel have increased.

Scatter Plots

gathering_data <- talks_data %>%
  mutate(
    gathering1 = str_count(tolower(text), "(?i)\\bgathering of israel\\b"),
    gathering2 = str_count(tolower(text), "(?i)\\bgathering israel\\b"),
    both_sides = str_count(tolower(text), "(?i)\\bboth sides of the veil\\b")
  ) %>% 
  mutate(gathering = gathering1 + gathering2)
  
gathering_pivot <- gathering_data %>% 
  select(year, speaker, title, gathering, both_sides) %>% 
  pivot_longer(
    cols = c(gathering, both_sides),
    names_to = "type",
    values_to = "count"
  ) %>% 
  group_by(year, type) %>% 
  summarise("total" = sum(count)) %>% 
  mutate(group = case_when(
    year < 2017 ~ "Before Nelson",
    year >= 2017 ~ "Post Nelson"
  ))

ggplot(data = gathering_pivot) +
  geom_point(mapping = aes(x = year, y = total, color = type)) +
  geom_smooth(se = FALSE, mapping = aes(x = year, y = total, color = type)) + 
  geom_vline(xintercept = 2017, color = "red") +
  theme_bw() +
  labs(
    title = "Use of Gathering Israel Related Words in General Conference Talks",
    subtitle = "2017 Highlighted - President Nelson sustained as Prophet",
    caption = '"Gathering Israel", "Both Sides of the Veil"',
    color = "Mention Type",
    x = "Year",
    y = "Mentions of Gathering Israel"
  )

Box Plot

gathering_means <- gathering_pivot %>% 
  group_by(group) %>% 
  summarise(mean = mean(total))

ggplot(data = gathering_pivot) + 
  geom_boxplot(mapping = aes(x = group, y = total)) + 
  geom_point(data = gathering_means, mapping = aes(x = group, y = mean), color = "red3") +
  theme_bw()

T Test

t.test(total ~ group, data = gathering_pivot, mu = 0, alternative = "two.sided", conf.level = 0.95) %>% 
  pander()
Welch Two Sample t-test: total by group (continued below)
Test statistic df P value Alternative hypothesis
-6.129 13.57 2.997e-05 * * * two.sided
mean in group Before Nelson mean in group Post Nelson
0.8696 8.286

Wilcoxon Test

wilcox.test(total ~ group, data = gathering_pivot, mu = 0, alternative = "two.sided", conf.level = 0.95) %>% 
  pander()
Wilcoxon rank sum test with continuity correction: total by group
Test statistic P value Alternative hypothesis
51.5 3.372e-09 * * * two.sided

Other Insights

Hide

Show

Missionary Work

(“Missionary”, “Missionaries”, “Every member a missionary”)

missionary_data <- talks_data %>%
  mutate(
    missionary = str_count(tolower(text), "(?i)\\bmissionary\\b"),
    missionaries = str_count(tolower(text), "(?i)\\bmissionaries\\b")
  )
  
missionary_pivot <- missionary_data %>% 
  select(year, speaker, title, missionary, missionaries) %>% 
  pivot_longer(
    cols = c(missionary, missionaries),
    names_to = "type",
    values_to = "count"
  ) %>% 
  group_by(year, type) %>% 
  summarise("total" = sum(count))


ggplot(data = missionary_pivot) +
  geom_point(mapping = aes(x = year, y = total, color = type)) +
  geom_smooth(mapping = aes(x = year, y = total)) + 
  geom_vline(xintercept = 1974, color = "red") +
  theme_bw() +
  labs(
    title = "Use of Temple Related Words in General Conference Talks",
    subtitle = "1974 Highlighted - Release of 'Go ye into all the World' by President Kimball",
    caption = '"Missionary", "Missionaries", "Every Member a Missionary"',
    color = "Mention Type",
    x = "Year",
    y = "Mentions of the Temple"
  )

Family History and Genealogy

(“Family History”, “Genealogy”)

family_search_data <- talks_data %>%
  mutate(
    family_history = str_count(tolower(text), "(?i)\\bfamily history\\b"),
    genealogy = str_count(tolower(text), "(?i)\\bgenealogy\\b")
  )
  
family_pivot <- family_search_data %>% 
  select(year, speaker, title, family_history, genealogy) %>% 
  pivot_longer(
    cols = c(family_history, genealogy),
    names_to = "type",
    values_to = "count"
  ) %>% 
  group_by(year, type) %>% 
  summarise("total" = sum(count))

ggplot(data = family_pivot) +
  geom_point(mapping = aes(x = year, y = total, color = type)) +
  geom_smooth(se = FALSE, mapping = aes(x = year, y = total, color = type)) + 
  geom_vline(xintercept = 1999, color = "red") +
  theme_bw() +
  labs(
    title = "Use of Temple Related Words in General Conference Talks",
    subtitle = "1999 Highlighted - Family Search Released World-wide",
    caption = '"Family Hisroty", "Genealogy"',
    color = "Mention Type",
    x = "Year",
    y = "Mentions of Family History"
  )

Gospel of Jesus Christ

(“Faith”, “Repentance”, “Baptism”, “Gift of the Holy Ghost”, “Endure to the End”)

gospel_principles <- talks_data %>%
  mutate(
    faith = str_count(tolower(text), "(?i)\\bfaith\\b"),
    repentance = str_count(tolower(text), "(?i)\\brepentance\\b"),
    baptism = str_count(tolower(text), "(?i)\\bbaptism\\b"),
    holy_ghost = str_count(tolower(text), "(?i)\\bgift of the holy ghost\\b"),
    endure = str_count(tolower(text), "(?i)\\bendure to the end\\b"),
  )
  
gospel_pivot <- gospel_principles %>% 
  select(year, speaker, title, faith, repentance, baptism, holy_ghost, endure) %>% 
  pivot_longer(
    cols = c(faith, repentance, baptism, holy_ghost, endure),
    names_to = "type",
    values_to = "count"
  ) %>% 
  group_by(year, type) %>% 
  summarise("total" = sum(count))

ggplot(data = gospel_pivot) +
  geom_point(mapping = aes(x = year, y = total, color = type)) +
  geom_smooth(se = FALSE, mapping = aes(x = year, y = total, color = type)) + 
  geom_vline(xintercept = 2008, color = "red") +
  theme_bw() +
  labs(
    title = "Use of Gospel of Jesus Christ Related Words in General Conference Talks",
    subtitle = "2008 Highlighted - Year President Monson became the Prophet.",
    caption = '"Faith", "Repentance", "Baptism", "Gift of the Holy Ghost", "Endure to the End"',
    color = "Mention Type",
    x = "Year",
    y = "Mentions of the Gospel of Jesus Christ"
  )

ggplot(data = filter(gospel_pivot, type != "faith")) +
  geom_point(mapping = aes(x = year, y = total, color = type)) +
  geom_smooth(se = FALSE, mapping = aes(x = year, y = total, color = type)) + 
  geom_vline(xintercept = 2008, color = "red") +
  theme_bw() +
  labs(
    title = "Use of Gospel of Jesus Christ Related Words in General Conference Talks",
    subtitle = "2008 Highlighted - Year President Monson became the Prophet.",
    caption = '"Repentance", "Baptism", "Gift of the Holy Ghost", "Endure to the End"',
    color = "Mention Type",
    x = "Year",
    y = "Mentions of the Gospel of Jesus Christ"
  )

gospel_principles <- talks_data %>%
  mutate(
    gospel = str_count(tolower(text), "(?i)\\bgospel of jesus christ\\b")
  )
  
gospel_pivot <- gospel_principles %>% 
  select(year, speaker, title, gospel) %>% 
  pivot_longer(
    cols = c(gospel),
    names_to = "type",
    values_to = "count"
  ) %>% 
  group_by(year, type) %>% 
  summarise("total" = sum(count))

ggplot(data = gospel_pivot) +
  geom_point(mapping = aes(x = year, y = total)) +
  geom_smooth(se = FALSE, mapping = aes(x = year, y = total)) + 
  geom_vline(xintercept = 2008, color = "red") +
  theme_bw() +
  labs(
    title = "Mentions of 'Gospel of Jesus Christ' in General Conference Talks",
    subtitle = "2008 Highlighted - Year President Monson became the Prophet.",
    caption = '"Gospel of Jesus Christ"',
    color = "Mention Type",
    x = "Year",
    y = "Mentions of the Gospel of Jesus Christ"
  )

Satan

(“Satan”, “Adversary”)

satan_data <- talks_data %>%
  mutate(
    satan = str_count(tolower(text), "(?i)\\bsatan\\b"),
    adversary = str_count(tolower(text), "(?i)\\badversary\\b"),
    lucifer = str_count(tolower(text), "(?i)\\blucifer\\b"),
    devil = str_count(tolower(text), "(?i)\\bdevil\\b")
  )
  
satan_pivot <- satan_data %>% 
  select(year, speaker, title, satan, adversary, lucifer, devil) %>% 
  pivot_longer(
    cols = c(satan, adversary, lucifer, devil),
    names_to = "type",
    values_to = "count"
  ) %>% 
  group_by(year, type) %>% 
  summarise("total" = sum(count))


ggplot(data = satan_pivot) +
  geom_point(mapping = aes(x = year, y = total, color = type)) +
  geom_smooth(se = FALSE, mapping = aes(x = year, y = total, color = type)) + 
  theme_bw() +
  labs(
    title = "Use of Satan Related Words in General Conference Talks",
    caption = '"Satan", "Adversary", "Lucifer", "Devil"',
    color = "Mention Type",
    x = "Year",
    y = "Mentions of Satan"
  )

Jesus

(“Jesus”, “Lord”, “Savior”)

jesus_data <- talks_data %>%
  mutate(
    jesus = str_count(tolower(text), "(?i)\\bjesus\\b"),
    lord = str_count(tolower(text), "(?i)\\blord\\b"),
    savior = str_count(tolower(text), "(?i)\\bsavior\\b"),
    christ = str_count(tolower(text), "(?i)\\bchrist\\b")
  )
  
jesus_pivot <- jesus_data %>% 
  select(year, speaker, title, jesus, lord, savior, christ) %>% 
  pivot_longer(
    cols = c(jesus, lord, savior, christ),
    names_to = "type",
    values_to = "count"
  ) %>% 
  group_by(year, type) %>% 
  summarise("total" = sum(count))


ggplot(data = jesus_pivot) +
  geom_point(mapping = aes(x = year, y = total, color = type)) +
  geom_smooth(se = FALSE, mapping = aes(x = year, y = total, color = type)) + 
  theme_bw() +
  labs(
    title = "Use of Jesus Related Words in General Conference Talks",
    caption = '"Jesus", "Lord", "Savior"',
    color = "Mention Type",
    x = "Year",
    y = "Mentions of Jesus"
  )

Prophet Names

(“President Nelson”, “Russell M. Nelson”, “Russell Nelson”)

prophets_data <- talks_data %>%
  mutate(
    nelson1 = str_count(tolower(text), "(?i)\\bpresident nelson\\b"),
    nelson2 = str_count(tolower(text), "(?i)\\brussell m. nelson\\b"),
    nelson3 = str_count(tolower(text), "(?i)\\brussell nelson\\b"),
    monson1 = str_count(tolower(text), "(?i)\\bpresident monson\\b"),
    monson2 = str_count(tolower(text), "(?i)\\bthomas s. monson\\b"),
    monson3 = str_count(tolower(text), "(?i)\\bthomas monson\\b"),
    hinckley1 = str_count(tolower(text), "(?i)\\bpresident hinckley\\b"),
    hinckley2 = str_count(tolower(text), "(?i)\\bgordon b. hinckley\\b"),
    hinckley3 = str_count(tolower(text), "(?i)\\bgordon hinckley\\b"),
    hunter1 = str_count(tolower(text), "(?i)\\bpresident hunter\\b"),
    hunter2 = str_count(tolower(text), "(?i)\\bhoward w. hunter\\b"),
    hunter3 = str_count(tolower(text), "(?i)\\bhoward hunter\\b"),
    benson1 = str_count(tolower(text), "(?i)\\bpresident benson\\b"),
    benson2 = str_count(tolower(text), "(?i)\\bezra taft benson\\b"),
    benson3 = str_count(tolower(text), "(?i)\\bezra benson\\b"),
    kimball1 = str_count(tolower(text), "(?i)\\bpresident kimball\\b"),
    kimball2 = str_count(tolower(text), "(?i)\\bspencer w. kimball\\b"),
    kimball3 = str_count(tolower(text), "(?i)\\bspencer kimball\\b"),
    lee1 = str_count(tolower(text), "(?i)\\bpresident lee\\b"),
    lee2 = str_count(tolower(text), "(?i)\\bharold b. lee\\b"),
    lee3 = str_count(tolower(text), "(?i)\\bharold lee\\b"),
    f_smith1 = str_count(tolower(text), "(?i)\\bpresident smith\\b"),
    f_smith2 = str_count(tolower(text), "(?i)\\bjoseph fielding smith\\b"),
    f_smith3 = str_count(tolower(text), "(?i)\\bjoseph f. smith\\b"),
    mckay1 = str_count(tolower(text), "(?i)\\bpresident mckay\\b"),
    mckay2 = str_count(tolower(text), "(?i)\\bdavid o. mckay\\b"),
    mckay3 = str_count(tolower(text), "(?i)\\bdavid mckay\\b")
  ) %>% 
  mutate(nelson = nelson1 + nelson2 + nelson3, 
         monson = monson1 + monson2 + monson3, 
         hinckley = hinckley1 + hinckley2 + hinckley3, 
         hunter = hunter1 + hunter2 + hunter3, 
         benson = benson1 + benson2 + benson3, 
         kimball = kimball1 + kimball2 + kimball3, 
         lee = lee1 + lee2 + lee3, 
         f_smith = f_smith1 + f_smith2 + f_smith3, 
         mckay = mckay1 + mckay2 + mckay3 
         )
  
prophets_pivot <- prophets_data %>% 
  select(year, speaker, title, nelson, monson, hinckley, hunter, benson, kimball, lee, f_smith, mckay) %>% 
  pivot_longer(
    cols = c(nelson, monson, hinckley, hunter, benson, kimball, lee, f_smith, mckay),
    names_to = "type",
    values_to = "count"
  ) %>% 
  group_by(year, type) %>% 
  summarise("total" = sum(count)) %>% 
  mutate(group = case_when(
    year < 2017 ~ "Before Nelson",
    year >= 2017 ~ "Post Nelson"
  ))

ggplot(data = prophets_pivot) +
  geom_point(mapping = aes(x = year, y = total, color = type)) +
  geom_smooth(se = FALSE, mapping = aes(x = year, y = total, color = type)) + 
  theme_bw() +
  labs(
    title = "Use of Each Prophet's Name in General Conference Talks over Time",
    # subtitle = "2017 Highlighted - President Nelson sustained as Prophet",
    caption = '"President Nelson", "Russell M. Nelson", "Russell Nelson"',
    color = "Prophet",
    x = "Year",
    y = "Mentions of Prophet Names"
  )

ggplot(data = filter(prophets_pivot, 
                     !type %in% c("nelson"))) +
  geom_point(mapping = aes(x = year, y = total), color = "grey") +
  geom_point(data = filter(prophets_pivot, 
                           type %in% c("nelson")), 
             mapping = aes(x = year, y = total, color = type)) +
  geom_smooth(data = filter(prophets_pivot, 
                           type %in% c("nelson")),
              se = FALSE, mapping = aes(x = year, y = total, color = type)) +
  geom_smooth(se = FALSE, mapping = aes(x = year, y = total, group = type), color = "grey") + 
  geom_vline(xintercept = 1995, color = "forestgreen") +
  geom_vline(xintercept = 2008, color = "forestgreen") +
  theme_bw() +
  labs(
    title = "Use of Each Prophet's Name in General Conference Talks over Time",
    # subtitle = "2017 Highlighted - President Nelson sustained as Prophet",
    caption = '"President Nelson", "Russell M. Nelson", "Russell Nelson"',
    color = "Prophet",
    x = "Year",
    y = "Mentions of Prophet Names"
  )
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'

Relief Society President Names

(“President Bingham”, “Jean B. Bingham”, “Jean Bingham”, “Sister Bingham”)

rs_data <- talks_data %>%
  mutate(
    spafford1 = str_count(tolower(text), "(?i)\\bpresident spafford\\b"),
    spafford2 = str_count(tolower(text), "(?i)\\bbelle s. spafford\\b"),
    spafford3 = str_count(tolower(text), "(?i)\\bbelle spafford\\b"),
    spafford4 = str_count(tolower(text), "(?i)\\bsister spafford\\b"),
    
    smith2 = str_count(tolower(text), "(?i)\\bbarbara b. smith\\b"),
    smith3 = str_count(tolower(text), "(?i)\\bbarbara smith\\b"),
    smith4 = str_count(tolower(text), "(?i)\\bsister smith\\b"),
    
    winder1 = str_count(tolower(text), "(?i)\\bpresident winder\\b"),
    winder2 = str_count(tolower(text), "(?i)\\bbarbara w. winder\\b"),
    winder3 = str_count(tolower(text), "(?i)\\bbarbara winder\\b"),
    winder4 = str_count(tolower(text), "(?i)\\bsister winder\\b"),
    
    jack1 = str_count(tolower(text), "(?i)\\bpresident jack\\b"),
    jack2 = str_count(tolower(text), "(?i)\\belaine l. jack\\b"),
    jack3 = str_count(tolower(text), "(?i)\\belaine jack\\b"),
    jack4 = str_count(tolower(text), "(?i)\\bsister jack\\b"),
    
    smoot1 = str_count(tolower(text), "(?i)\\bpresident smoot\\b"),
    smoot2 = str_count(tolower(text), "(?i)\\bmary ellen w. smoot\\b"),
    smoot3 = str_count(tolower(text), "(?i)\\bmary ellen smooth\\b"),
    smoot4 = str_count(tolower(text), "(?i)\\bsister smoot\\b"),
    
    parkin1 = str_count(tolower(text), "(?i)\\bpresident parkin\\b"),
    parkin2 = str_count(tolower(text), "(?i)\\bbonnie d. parkin\\b"),
    parkin3 = str_count(tolower(text), "(?i)\\bbonnie parkin\\b"),
    parkin4 = str_count(tolower(text), "(?i)\\bsister parkin\\b"),
    
    beck1 = str_count(tolower(text), "(?i)\\bpresident beck\\b"),
    beck2 = str_count(tolower(text), "(?i)\\bjulie b. beck\\b"),
    beck3 = str_count(tolower(text), "(?i)\\bjulie beck\\b"),
    beck4 = str_count(tolower(text), "(?i)\\bsister beck\\b"),
    
    burton1 = str_count(tolower(text), "(?i)\\bpresident burton\\b"),
    burton2 = str_count(tolower(text), "(?i)\\blinda k. burton\\b"),
    burton3 = str_count(tolower(text), "(?i)\\blinda burton\\b"),
    burton4 = str_count(tolower(text), "(?i)\\bsister burton\\b"),
    
    bingham1 = str_count(tolower(text), "(?i)\\bpresident bingham\\b"),
    bingham2 = str_count(tolower(text), "(?i)\\bjean b. bingham\\b"),
    bingham3 = str_count(tolower(text), "(?i)\\bjean bingham\\b"),
    bingham4 = str_count(tolower(text), "(?i)\\bsister bingham\\b"),
    
    johnson1 = str_count(tolower(text), "(?i)\\bpresident johnson\\b"),
    johnson2 = str_count(tolower(text), "(?i)\\bcamille n. johnson\\b"),
    johnson3 = str_count(tolower(text), "(?i)\\bcamille johnson\\b"),
    johnson4 = str_count(tolower(text), "(?i)\\bsister johnson\\b")
    
  ) %>% 
  mutate(spafford = spafford1 + spafford2 + spafford3 + spafford4,
         smith = smith2 + smith3 + smith4,
         winder = winder1 + winder2 + winder3 + winder4,
         jack = jack1 + jack2 + jack3 + jack4,
         smoot = smoot1 + smoot2 + smoot3 + smoot4,
         parkin = parkin1 + parkin2 + parkin3 + parkin4,
         beck = beck1 + beck2 + beck3 + beck4,
         burton = burton1 + burton2 + burton3 + burton4,
         bingham = bingham1 + bingham2 + bingham3 + bingham4,
         johnson = johnson1 + johnson2 + johnson3 + johnson4

         )
  
rs_pivot <- rs_data %>% 
  select(year, speaker, title, spafford, smith, winder, jack, smoot, parkin, beck, burton, bingham, johnson) %>% 
  pivot_longer(
    cols = c(spafford, smith, winder, jack, smoot, parkin, beck, burton, bingham, johnson),
    names_to = "type",
    values_to = "count"
  ) %>% 
  group_by(year, type) %>% 
  summarise("total" = sum(count)) %>% 
  mutate(group = case_when(
    year < 2017 ~ "Before Nelson",
    year >= 2017 ~ "Post Nelson"
  ))

# Given names
names <- c("spafford", "smith", "winder", "jack", "smoot", "parkin", "beck", "burton", "bingham", "johnson")

# Custom color palette
custom_colors <- c("#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf")

# Creating a named vector of colors for each type
color_palette <- setNames(custom_colors, names)

rs_pivot$type <- factor(rs_pivot$type, levels = c("spafford", "smith", "winder", "jack", "smoot", "parkin", "beck", "burton", "bingham", "johnson"))

rs_plot <- ggplot(data = rs_pivot) +
  geom_bar(mapping = aes(x = year, y = total, fill = type), stat = "identity") +
  scale_fill_manual(values = color_palette) +
  theme_bw() +
  labs(
    title = "Use of Each RS President's Name in General Conference Talks over Time",
    subtitle = '"President Smith" omitted due to confusions with Prophets',
    caption = '"President Bingham", "Jean B. Bingham", "Jean Bingham", "Sister Bingham"',
    color = "President",
    x = "Year",
    y = "Mentions of RS President's Names"
  )

ggplotly(rs_plot)